<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width,initial-scale=1.0">
  <link rel="icon" href="<%= BASE_URL %>favicon.ico">


  <title>华为商城（VMALL.COM）_华为手机、荣耀手机、官网正品保障</title>

</head>

<body>
  <noscript>
    <strong>We're sorry but <%= htmlWebpackPlugin.options.title %> doesn't work properly without JavaScript enabled.
      Please enable it to continue.</strong>
  </noscript>
  <div id="app"></div>
  <!-- built files will be auto injected -->

  <!--侧边导航-->
  <script src="http://apps.bdimg.com/libs/jquery/1.9.1/jquery.min.js"></script>
  <script type="text/javascript">
    $(function () {
      $(window).bind("scroll", function () {
        var sTop = $(window).scrollTop();
        var sTop = parseInt(sTop);
        if (sTop >= 2300 && sTop <= 9800) {
          if (!$("#cebiandaohang_div").is(":visible")) {
            try {
              $("#cebiandaohang_div").slideDown();
            } catch (e) {
              $("#cebiandaohang_div").show();
            }
          }
        }
        else {
          if ($("#cebiandaohang_div").is(":visible")) {
            try {
              $("#cebiandaohang_div").slideUp();
            } catch (e) {
              $("#cebiandaohang_div").hide();
            }
          }
        }
      });
    })
    $(document).ready(function () {
      // scrollTo('.mainMenu-links')		;
      scrollTo();
      scrollToTop();
    });

    function scrollTo() {
      $('.mainMenu a').click(function (e) {
        e.preventDefault();
        $('.mainMenu a').removeClass('active');
        $(this).addClass('active');

        var distanceTopToSection = $('#' + $(this).data('target')).offset().top;

        $('body, html').animate({ scrollTop: distanceTopToSection }, 'slow');
      });
    }


    function scrollToTop() {
      var backToTop = $('.backToTop');
      var showBackTotop = $(window).height();
      backToTop.hide();

      var children = $(".mainMenu li").children();
      var tab = [];
      for (var i = 0; i < children.length; i++) {
        console.log(children[i]);
        var child = children[i];
        var ahref = $(child).attr('href');
        console.log(ahref);
        tab.push(ahref);
      }


      $(window).scroll(function () {
        var windowScrollTop = $(window).scrollTop();
        if (windowScrollTop > showBackTotop) {
          backToTop.fadeIn('slow');
        } else {
          backToTop.fadeOut('slow');
        }

        var windowHeight = $(window).height();
        var docHeight = $(document).height();

        for (var i = 0; i < tab.length; i++) {
          var link = tab[i];
          var divPos = $(link).offset().top;
          var divHeight = $(link).height();
          if (windowScrollTop >= divPos && windowScrollTop < (divPos + divHeight)) {
            $(".mainMenu a[href='" + link + "']").addClass("active");
          } else {
            $(".mainMenu a[href='" + link + "']").removeClass("active");
          }
        }

        if (windowScrollTop + windowHeight == docHeight) {
          if (!$(".mainMenu li:last-child a").hasClass("active")) {
            var navActive = $(".active").attr("href");
            $(".mainMenu a[href='" + navActive + "']").removeClass("active");
            $(".mainMenu li:last-child a").addClass("active");
          }
        }
      });

      backToTop.click(function (e) {
        e.preventDefault();
        $(' .mainMenu li a ').removeClass('active');
        $(' .mainMenu li a:first ').addClass('active');
        $(' body, html ').animate({ scrollTop: 0 }, 'slow');
      });
    }
  </script>
</body>

</html>